 
layui.define(['form','xmSelect','tableSelect','upload','admin','laydate'], function(exports){
	 var $ = layui.$
	    ,form = layui.form
	    ,setter = layui.setter
	    ,laydate = layui.laydate
	    ,tableSelect = layui.tableSelect
	    ,xmSelect = layui.xmSelect
		 ,admin = layui.admin
	 	,upload = layui.upload
		 ,count=0
		 ,table=layui.table;
	    $("select[name='source']").attr("disabled","disabled");
		form.render('select');

	var colsArr;
	var tableTitle;
	var tableField; //表头字段
	var tableSearch = [];//全局搜索条件
	var tableHead;//表头字段
	//日期
	laydate.render({
		elem: '#entry_time'
	});
	laydate.render({
		elem: '#birth'
	});
	laydate.render({
		elem: '#expire'
	});
	laydate.render({
		elem: '#entry_time'
	});
	laydate.render({
		elem: '#entry_time'
	});
	function loadTable(header){
		colsArr = [
			{field: 'gz_start', title: '开始日期',sort:true,align:'center',hide:true},
			{field: 'gz_over', title: '结束日期',sort:true,align:'center'},
			{field: 'gz_bumen', title: '部门',sort:true,align:'center',width: 100, sort: true,},
			{field: 'gz_gangwei', title: '岗位',align:'center',sort:true,sort: true,width: 130,},
		];
		layui.each(colsArr,function(inx,val){
			tableHead += val.hasOwnProperty('field')?val.field:'-';
			tableHead += ',';
			tableTitle += val.hasOwnProperty('title')?(val.hide?'':val.title+','):',';
			tableField += val.hasOwnProperty('field')?(val.hide?'':val.field+','):',';
		})
		//tableHead是获取表字段
		tableHead = tableHead.substring(tableHead.indexOf(',')+1,tableHead.length-1);
		//导出时需要用到标题
		tableTitle = tableTitle.substring(tableTitle.indexOf(',')+1,tableTitle.length-1);
		//导出需要用到实际导出的字段
		tableField = tableField.substring(tableField.indexOf(',')+1,tableField.length-1);

		//用户管理
		table.render({
			elem: '#LAY-human-gzjl'
			,url: setter.host + '/human/menu/getGongzuo'

			,cols: [colsArr]
			//,toolbar: 'true'
			//,defaultToolbar: ['print']
			,method:'post'
			,contentType:'application/json; charset=utf-8'
			,where:{'headField':"gz_start,gz_over,gz_bumen,gz_gangwei",'user_id':$('#user_id').val()}
			,page: true
			,groups:2
			,limit: 15
			,limits:[15,30,50]
			,height: 'full-60'
			,width:'750px'
			,text: {
				none: '暂无相关数据'
			}
			,done:function () {
				delete this.where;
			}
		});
	}

	$.ajax({
		url: setter.host+'/adminmanager/user/getSelectHead'
		,type:'get'
		,dataType:'json'
		,success: function(res){
			//请求成功后
			if(res.status == setter.response.statusCode.status_Success){
				loadTable(res.data.field);
			}else{
				window.location.href = setter.host+'/error/toNoPower?msg='+res.msg;
			}
		}
	});
  //对外暴露的接口
    exports('gongzuojilu', {});
});